/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.spadons.esmetil.sessionBeans.viewSessionBeans;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import py.com.spadons.esmetil.entities.EstacionDetalle;
import py.com.spadons.esmetil.entities.views.DatoAnho;

/**
 *
 * @author spadons
 */
@Stateless
public class DatoAnhoFacade extends AbstractFacade<DatoAnho> {
    @PersistenceContext(unitName = "EsmetilPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public DatoAnhoFacade() {
        super(DatoAnho.class);
    }
    
    public List<DatoAnho> findByAnho(String anho, EstacionDetalle estacionDetalle){
        TypedQuery<DatoAnho> query = em.createNamedQuery("DatoAnho.findByAnho", DatoAnho.class);
        query.setParameter("anho", anho);
        query.setParameter("estacionDetalle", estacionDetalle.getCodigo());
         
        List<DatoAnho> datoAnhoList = query.getResultList();
        
        return datoAnhoList;
    }
    
}
